<?php
/**
 * autoshow类
 * @copyright   2011 友拓软件友拓通
 * @category   	通用
 * @package  	Action 
 * @version 	2011-03-25
 * @author 		黄明兴
 */
class AutoShowPublicAction extends CommonAction {

	public function _initialize(){
		parent::_initialize();
		C('SHOW_PAGE_TRACE',false);
	}

	/// 构造函数
	public function __destruct(){
		exit;
	}


	/// autoshow
	public function index(){
		addLang('Product');
		/// 不同的流程显示不同的内容
		$id = intval($_POST['id']);
		$module = $_POST['module'];
//		$this->getProductInfo($id);
		
		switch ($module) {
			case 'SaleOrder':
			case 'ReturnSaleOrder':
			case 'SaleStorage':
				$this->storage = _formatList(D('StorageShow')->getProductSaleStorage($id));
				$tpl_name = 'saleStorage';
				break;
			case 'PreDelivery':
			case 'Delivery':
			case 'Stocktake':
			case 'Profitandloss':
			case 'RealStorage':
				if (!C('STORAGE_ZERO')) {$where = ' and quantity!=0';}
				$this->storage = _formatList(M('Storage')->field('*,(quantity*capability*dozen) as real_storage')->where('product_id='.$id.$where)->select());
				$tpl_name = 'realStorage';
				break;
                        case 'Glass':
                                $this->getGlassInfo($id);
                                $tpl_name = 'glass';
                            break;
			default:
				$tpl_name = 'product';
				break;
		}
		$this->display($tpl_name);
	}

	private function getProductInfo($id){
		$vo = D('Product')->getInfo($id,'view');
		$this->assign ('rs',$vo);
		$this->assign ('dd_color',S('color'));
		$this->assign ('dd_size',S('size'));
		$temp 	= S('currency');
		$cur	= array('in'=>$temp[1],'out'=>$temp[C('CURRENCY')]);
		$this->assign('cur',$cur);
	}
        
        private function getGlassInfo($id){
            $rs = _formatArray(M('glass')->find($id));
//            echo '<pre>';print_r($rs);
            $this->assign('rs',$rs);
        }


}
?>